package logic

import (
	"context"

	"activity/activityRpc/activityRpc"
	"activity/activityRpc/internal/svc"
	"activity/models/mysql"
	"github.com/zeromicro/go-zero/core/logx"
)

type ReplyListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewReplyListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReplyListLogic {
	return &ReplyListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ReplyListLogic) ReplyList(in *activityRpc.ReplyListRequest) (*activityRpc.ReplyListResponse, error) {
	// todo: add your logic here and delete this line

	var replys []mysql.Reply
	mysql.DB.Find(&replys)

	var replysList []*activityRpc.ReplyList
	for _, reply := range replys {
		list := activityRpc.ReplyList{
			UserId:     int64(reply.UserId),
			ActivityId: int64(reply.ActivityId),
			ConTent:    reply.Content,
		}
		replysList = append(replysList, &list)
	}
	return &activityRpc.ReplyListResponse{
		List: replysList,
	}, nil
}
